package com.roc.web.action.operator;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class OperatorCheckSearchCondition extends BaseSearchCondition {

	private String orgCode;
	private String accountNo;
	private String realName;
	private String cardNo;
	private String mobile;
	private String roleType;
//	private String roleCode;
//	private Long id;
	
	private String[] agentId;//所属代理商
	
	
	
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		// TODO Auto-generated method stub
        List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if (Constance.isNotEmpty(accountNo)) {
			filedBeanList.add(new WhereHQLFieldBean("o.accountNo", accountNo.trim(), "=", false));
		}

		if (Constance.isNotEmpty(realName)) {
			filedBeanList.add(new WhereHQLFieldBean("o.realName", realName.trim(),
					"LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(mobile)) {
			filedBeanList.add(new WhereHQLFieldBean("o.mobile", mobile.trim(), "=", false));
		}
		if (Constance.isNotEmpty(cardNo)) {
			filedBeanList.add(new WhereHQLFieldBean("o.cardNo", cardNo.trim(), "=", false));
		}
		
        
		if (Constance.isNotEmpty(orgCode)&&!"99".equals(orgCode)) {
				filedBeanList.add(new WhereHQLFieldBean("o.orgCode", orgCode.trim(), "=", false));
		}
		if (Constance.isNotEmpty(roleType)&&!"99".equals(roleType)) {
			filedBeanList.add(new WhereHQLFieldBean("o.roleType", roleType.trim(), "=", false));
	    }
		if(agentId!=null&&agentId.length >0){//代理商
	        	filedBeanList.add(new WhereHQLFieldBean("o.id IN("+Constance.getArrayContent(agentId)+")"));
	     }

		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		// TODO Auto-generated method stub
		return " select count(*) from Operators o  where o.status='01' and o.roleType not in('00','02','03','15') ";
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		return " from Operators o where  o.status='01'  and o.roleType not in('00','02','03','15') ";
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return " order by o.dtCreate asc ";
	}
	
	
	
	
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getRoleType() {
		return roleType;
	}

	public void setRoleType(String roleType) {
		this.roleType = roleType;
	}

	public String[] getAgentId() {
		return agentId;
	}

	public void setAgentId(String[] agentId) {
		this.agentId = agentId;
	}

}
